<template>
	<view v-if="isNew" class="custom-tabbar">
		<view v-for="(item, index) in tabList" :key="index" class="tab-item"
			:class="[item.centerItem ? ' center-item' : '', currentIndex === index ? 'active' : '']"
			@click="switchTab(index, item.pagePath)">
			<view class="icon-view">
				<image :src="currentIndex === index ? item.selectedIconPath : item.iconPath" class="icon" />
				<text>{{ item.text }}</text>
			</view>
		</view>
	</view>
	<view v-else class="custom-tabbar">
		<view v-for="(item, index) in tabList" :key="index" class="tab-item" :class="{ active: currentIndex === index }"
			@click="switchTab(index, item.pagePath)">
			<image :src="currentIndex === index ? item.selectedIconPath : item.iconPath" class="icon" />
			<text>{{ item.text }}</text>
		</view>
	</view>
</template>

<script>
	export default {
		props: {
			currentIndex: {
				type: Number,
				default: 0
			},
			// deepseek特殊样式
			isNew: {
				type: Boolean,
				default: true
			}

		},
		data() {
			return {
				tabList: [{
						pagePath: "/pages/index",
						iconPath: "/static/images/tabbar/xiaoxi.png",
						selectedIconPath: "/static/images/tabbar/xiaoxiActive.png",
						text: "消息",
						centerItem: false,
					},
					{
						pagePath: "/pages/work/index",
						iconPath: "/static/images/tabbar/xiezuo.png",
						selectedIconPath: "/static/images/tabbar/xiezuoActive.png",
						text: "协作",
						centerItem: false,
					},
					{
						pagePath: "/pages/deepseek/index",
						iconPath: "/static/images/tabbar/deepseek.png",
						selectedIconPath: "/static/images/tabbar/deepseekActive.png",
						text: "deepseek",
						centerItem: true,
					},
					{
						pagePath: "/pages/learn/index",
						iconPath: "/static/images/tabbar/xuexi.png",
						selectedIconPath: "/static/images/tabbar/xuexiActive.png",
						text: "学习",
						centerItem: false,
					},
					{
						pagePath: "/pages/mine/index",
						iconPath: "/static/images/tabbar/tongxunlv.png",
						selectedIconPath: "/static/images/tabbar/tongxunlvActive.png",
						text: "通讯录",
						centerItem: false,
					}
				]
			};
		},
		methods: {
			switchTab(index, pagePath) {
				if (this.currentIndex !== index) {
					uni.switchTab({
						url: pagePath
					});
				}
			}
		}
	};
</script>

<style scoped lang="scss">

	.custom-tabbar {
		position: fixed;
		bottom: 0;
		left: 0;
		right: 0;
		display: flex;
		justify-content: space-around;
		background-color: #fff;
		padding: 20rpx 0;
		box-shadow: 0 8rpx 8rpx 0 #4d6bff1a;
	}

	.center-item {
		display: block;
		position: relative;
		padding: 20rpx;

		.icon-view {
			flex-shrink: 0;
			width: 140rpx;
			height: 140rpx;
			position: absolute;
			top: -60rpx;
			left: calc(50% - 70rpx);
			border-radius: 50%;
			box-shadow: 0 8rpx 8rpx 0 #4d6bff1a;
			background-color: #ffffff;
			display: flex;
			flex-direction: column;
			align-items: center;
			justify-content: center;
		}
	}
	
	.icon-view{
		display: flex;
		flex-direction: column;
		align-items: center;
	}

	.tab-item {
		display: flex;
		flex-direction: column;
		align-items: center;
		color: #86909C;
		font-size: 20rpx
	}

	.tab-item.active {
		color: #007AFF;
	}

	.icon {
		width: 48rpx;
		height: 48rpx;
		margin-bottom: 10rpx;
	}
</style>